/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
#ifndef TRACKTABLE_H
#define TRACKTABLE_H

#include "IncFreeTrack.h"
#include "freetrackwidget.h"
#include "trackpoint.h"

class LayerManager;
class FTPushButton;

class TrackTable : public FreeTrackWidget
{
    Q_OBJECT
public:
    explicit TrackTable(QWidget *parent, LayerManager* );
    ~TrackTable();
    // Paint the table...
    void paintEvent ( QPaintEvent * event );
    // Manage mouse events, to support for dragging the table around!
    void mousePressEvent ( QMouseEvent * event );
    void mouseReleaseEvent ( QMouseEvent * event );
    void mouseMoveEvent ( QMouseEvent * event );

    static TrackTable* staticGet();

public slots:
    void zoomIn();
    void zoomOut();
    void followMode();
    void gpsUpdated(const TrackPoint&);
    void gpsStatusChanged(bool);
    void addWaypoint();

private:
    // Keep track of layers
    LayerManager* layers;
    // Keep track of the latest GPS update
    TrackPoint gps_center;
    // Is gps fixed?
    bool gps_has_fix;

    // Buttons
    FTPushButton * zoom_in;
    FTPushButton * zoom_out;
    FTPushButton * follow;
    FTPushButton * waypoint;

    // Track current screen center (offset-factor)
    QPointF screen_center;
    // and scale factor (from pixel to lon/lat)
    qreal screen_scale;
    int zoom_step;
    // Also we need this to track mouse-related tracking when panning
    QPointF mouse_start;

    QLayout* createHorizontal();
    QLayout* createVertical();
};

#endif // TRACKTABLE_H
